package com.example.controller;

import com.example.pojo.dto.JobIntentionDTO;
import com.example.pojo.entity.JobIntention;
import com.example.service.JobIntentionService;
import com.example.vo.Result;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 本文来演示:求职期望
 *
 * @author 赵建云
 * @create 2023/10/13
 */
@RestController
@RequestMapping("intention")
public class JobIntentionController {
    @Autowired
    private JobIntentionService jobIntentionService;
    @GetMapping("hope")
    public Result hope(Integer jsId){
        List<String> list = jobIntentionService.searchHope(jsId);
        if (list!=null&&list.size()>0){
            return new Result(200,"期望职位查询",list);
        }else {
            return new Result(500,"无期望职位，先添加");
        }
    }

    @PostMapping("saveOrUpdateHope")
    public Result saveOrUpdateHope(JobIntentionDTO jobIntentionDTO){
        System.out.println(jobIntentionDTO);
        int count = jobIntentionService.saveOrUpdateHope(jobIntentionDTO);
        if (count==1){
            return new Result(200,"保存或更新成功");
        }else {
            return new Result(500,"更新或保存失败");
        }
    }

    @PostMapping("findHopes")
    public Result findHopes(Integer jsId){
        List<JobIntentionDTO> list = jobIntentionService.findHopes(jsId);
        if (list!=null&&list.size()>0){
            return new Result(200,"所有期望",list);
        }else {
            return new Result(500,"没有期望职位");
        }
    }




}
